import { defineStore } from 'pinia';

export type MenuItem = {
  id: string;
  label: string;
  action?: string;
  accelerator?: string;
  enabled?: boolean | ((ctx?: any) => boolean);
  visible?: boolean | ((ctx?: any) => boolean);
  submenu?: MenuItem[];
};

export const useMenuStore = defineStore('menu', {
  state: () => ({
    menubar: [] as MenuItem[],
    context: null as any,
    openMenuId: '',
  }),
  actions: {
    setMenubar(items: MenuItem[]) { this.menubar = items || []; },
    setContext(ctx: any) { this.context = ctx || null; },
    setOpenMenu(id: string) { this.openMenuId = id; },
    closeAll() { this.openMenuId = ''; this.context = null; },
  },
});


